package com.zhangliuliu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangliuliu.bean.AreaBean;
import com.zhangliuliu.dao.AreaDao;
import com.zhangliuliu.service.AreaService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AreaServiceImpl extends ServiceImpl<AreaDao, AreaBean> implements AreaService {
    @Override
    public void addArea(AreaBean areaBean) {
        save(areaBean);
    }

    @Override
    public IPage<AreaBean> cutByItem(int pageNo, int pageSize, String name, String kind, String groupName) {
        Page<AreaBean> Page = new Page<>(pageNo, pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (name!=null&&!name.equals("")){
            wrapper.eq("area_name",name);
        }
        if (kind!=null&&!kind.equals("")){
            wrapper.eq("tree_kind",kind);
        }
        if (groupName!=null&&!groupName.equals("")){
            wrapper.eq("groupName",groupName);
        }
      IPage<AreaBean> iPage= this.page(Page,wrapper );
        return iPage;
    }

    @Override
    public IPage<AreaBean> cutByItem1(int pageNo, int pageSize) {
        Page<AreaBean> Page = new Page<>(pageNo, pageSize);
       return this.page(Page,null);
    }


}
